package com.atguigu.common.config.exception;

import com.atguigu.common.result.ResultCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * className: GuiguException
 * description:
 * date: 2023/4/12 0012-23:28
 * <p>
 * project: guigu-oa-parent
 * package: com.atguigu.common.config.exception
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class GuiguException extends RuntimeException {

    /**
     * 状态码
     */
    private Integer code;
    /**
     * 描述信息
     */
    private String msg;

    public GuiguException(Integer code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    /**
     * 接受枚举类型对象
     *
     * @param resultCodeEnum {@link ResultCodeEnum}
     */
    public GuiguException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.msg = resultCodeEnum.getMessage();
    }

    @Override
    public String toString() {
        return "GuiguException{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }
}
